//
//  IndentCell.m
//  cm
//
//  Created by suyibaishan on 2017/11/7.
//  Copyright © 2017年 feihu. All rights reserved.
//

#import "IndentCell.h"

@implementation IndentCell
{
    UIImageView *picture;
    UILabel *titleLabel;
    UILabel *priceLabel;
}
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self constructUI];
    }
    return self;
}

-(void)constructUI
{
    picture = [[UIImageView alloc] init];
    picture.layer.cornerRadius = 5;
//    picture.contentMode = UIViewContentModeScaleAspectFill;
//    picture.clipsToBounds = YES;
    [self.contentView addSubview:picture];
    picture.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(65)
    .heightIs(65);
    picture.backgroundColor = [UIColor redColor];
    
    titleLabel = [[UILabel alloc] init];
    titleLabel.numberOfLines = 2;
//    titleLabel.text = @"广州讴歌广州讴歌广州讴歌广州讴歌广州讴歌广州讴歌广州讴歌广州讴歌广州讴歌广州讴歌";
    titleLabel.textColor = [UIColor blackColor];
    titleLabel.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:titleLabel];
    titleLabel.sd_layout
    .leftSpaceToView(picture, 10)
    .topSpaceToView(self.contentView, 12)
    .widthIs(kScreenWidth/2)
    .heightIs(35);
    
    priceLabel = [[UILabel alloc] init];
//    priceLabel.text = [NSString stringWithFormat:@"指导价¥9111.00 首付价¥9111.00"];
    //        _priceLab.backgroundColor = [UIColor grayColor];
    priceLabel.textColor = [UIColor blackColor];
    priceLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:priceLabel];
    priceLabel.sd_layout
    .leftSpaceToView(picture, 10)
    .topSpaceToView(titleLabel, 5)
    .widthIs(kScreenWidth - 95)
    .heightIs(20);
    
    _numLabel = [[UILabel alloc]init];
    _numLabel.text = @"x1";
    _numLabel.textAlignment = NSTextAlignmentRight;
    //        _normLabel.backgroundColor = [UIColor grayColor];
    _numLabel.textColor = [UIColor blackColor];
    _numLabel.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:_numLabel];
    _numLabel.sd_layout
    .topSpaceToView(self.contentView, 10)
    .rightSpaceToView(self.contentView, 10)
    .widthIs(50)
    .heightIs(20);
    
    UIView *line = [[UIView alloc] init];
    line.backgroundColor = [UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1];
    [self.contentView addSubview:line];
    line.sd_layout
    .leftSpaceToView(self.contentView, 0)
    .bottomSpaceToView(self.contentView, 0)
    .widthIs(kScreenWidth)
    .heightIs(1);
}

-(void)setModel:(IndentModel *)model
{
    _model = model;
    [picture sd_setImageWithURL:[NSURL URLWithString:[kIMGURL stringByAppendingString:model.imageUrl]] placeholderImage:nil];
    titleLabel.text = model.goodsTitle;
    priceLabel.text = model.type == 2 ? [NSString stringWithFormat:@"积分%@",model.points]:[NSString stringWithFormat:@"指导价¥%.2f  首付价¥%.2f",model.price,model.downPayment];// 首付价¥9111.00
    _numLabel.text = [NSString stringWithFormat:@"共%ld件",model.quantity];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
